//
//  InfoTopView.m
//  ejiaqingAlertView
//
//  Created by 杨攀 on 16/10/13.
//  Copyright © 2016年 CMIG. All rights reserved.
//

#import "InfoTopView.h"
#import <Masonry.h>
@interface InfoTopView ()

/** 卡劵名 */
@property (nonatomic,strong) UILabel *titleLabel;
/** cancelBtn */
@property (nonatomic,strong) UIButton *cancelBtn;
/** topLine */
@property (nonatomic,strong) UILabel  *topLine;
/** bottomLine */
@property (nonatomic,strong) UILabel *bottomLine;

@end

@implementation InfoTopView

- (instancetype)init
{
    if (self = [super init]) {
        [self initUI];
    }
    return self;
}
- (void)initUI{
    _topLine = [UILabel new];
    _topLine.backgroundColor = [UIColor colorWithRed:64/255.0 green:200/255.0 blue:224/255.0 alpha:1.0];
    [self addSubview:_topLine];
    
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.font = [UIFont systemFontOfSize:14.f];
    _titleLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:_titleLabel];
    
    _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_cancelBtn setImage:[UIImage imageNamed:@"cancel_btn"]  forState:UIControlStateNormal];
    [_cancelBtn setImageEdgeInsets:UIEdgeInsetsMake(7.5, 7.5, 7.5, 7.5)];
    [_cancelBtn addTarget:self action:@selector(cancel) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_cancelBtn];
    
    _bottomLine = [UILabel new];
    _bottomLine.backgroundColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:244/255.0 alpha:1.0];
    [self addSubview:_bottomLine];
}
- (void)setTitleName:(NSString *)titleName
{
    _titleName = titleName;
    _titleLabel.text = _titleName;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    [_topLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(self);
        make.height.equalTo(@1);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(50);
        make.left.equalTo(self).offset(-50);
        make.centerY.equalTo(self.mas_centerY);
    }];
    [_cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-10);
        make.centerY.equalTo(self);
        make.size.mas_equalTo(CGSizeMake(40, 40));
    }];
    
    [_bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.bottom.equalTo(self);
        make.height.equalTo(@1);
    }];
}
- (void)cancel{
    
}
@end
